package com.spring.boot.controller;

import com.spring.boot.entity.Contract;
import com.spring.boot.service.ContractService;
import com.spring.boot.vo.ContractParametersVO;
import com.spring.boot.vo.ContractTypeAndContractUuidVO;
import com.spring.boot.vo.FindContractList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author: ZTQ
 * @Date: 2021/01/01 17:26
 * @Description: TODO 合同管理 控制器
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/contract")
public class ContractController {
    @Autowired
    private ContractService contractService;

    /**
     * @param contract 合同对象
     * @description: 添加合同（普通用户）
     */
    @PostMapping(value = "/addContract", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> addContract(@RequestBody Contract contract) {
        //调用合同service层的addContract方法，进行新增险种操作
        Map<String, Object> stringObjectMap = contractService.addContract(contract);
        //返回数据信息
        return stringObjectMap;
    }


    /**
     * @param contractUuid 合同uuid
     * @description: 查询合同详情
     */
    @GetMapping(value = "/findContractDetails", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> findContractDetails(@RequestParam String contractUuid) {
        //调用合同service层的findContractListByUid方法，进行查询合同信息详情
        Map<String, Object> contractListByUid = contractService.findContractDetails(contractUuid);
        //返回数据信息
        return contractListByUid;
    }


    /**
     * @param findContractList 自定义对象
     * @description: 查询合同列表
     */
    @PostMapping(value = "/findContractListByUid", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> findContractListByUid(@RequestBody FindContractList findContractList) {
        //调用service层的findContractList方法，查询所有合同列表
        Map<String, Object> contractList = contractService.findContractList(findContractList);
        //返回数据信息
        return contractList;
    }
    /**
     * @param contractUuid 合同uuid
     * @description: 财务确认收款接口
     */
    @GetMapping(value = "/updateContractType", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map<String, Object> updateContractType(@RequestParam String contractUuid) {
        //调用合同service层的updateContractType方法，进行新增险种操作
        Map<String, Object> stringObjectMap = contractService.updateContractType(contractUuid);
        //返回数据信息
        return stringObjectMap;
    }

}
